int MyImg::Show(){
	CvImage img(thisFilename.data(), 0, CV_LOAD_IMAGE_COLOR);

	if( !img.data() ){
		cout << "IMAGE NOT FOUND" << endl;
		return(-1);
	}
	else{
		//cout << "Image found:"<< img.size().height << endl;
		cvNamedWindow( thisFilename.data(), CV_WINDOW_AUTOSIZE );
		img.show(thisFilename.data());
		cvWaitKey();
		img.release();
		return(0);
	}

}

MyImg::MyImg(){
	FFTexist	=	false;
        fft     =   NULL;
        fftR    =   NULL;
        fftG    =   NULL;
        fftB    =   NULL;
	//CvHistogram	*hist;

        thisimg =   NULL;
}
MyImg::~MyImg(){
    Clean();
}
void MyImg::Clean(){
    FFTexist    =   false;
    if(fft!=NULL){
        fftw_free(fft);
        fft=NULL;
    }
    if(fftB!=NULL){
        fftw_free(fftB);
        fftB=NULL;
    }
    if(fftG!=NULL){
        fftw_free(fftG);
        fftG=NULL;
    }
    if(fftR!=NULL){
        fftw_free(fftR);
        fftR=NULL;
    }
    if(thisimg!=NULL){
        cvReleaseImage(&thisimg);
        thisimg=NULL;
    }
}

void MyImg::OpenImage(int mode){
    IplImage *temp;
    unsigned char* ptr=NULL;
    unsigned char* ptemp=NULL;
    int k,j,l;

    if(mode == GRAYSCALE_MODE){
        thisimg	=cvLoadImage(thisFilename.data(), CV_LOAD_IMAGE_GRAYSCALE );
        return;
    }

    thisimg     =cvLoadImage(thisFilename.data(), CV_LOAD_IMAGE_COLOR );

    ptr     =(unsigned char*) thisimg->imageData;

    temp    =cvCreateImage( cvGetSize(thisimg),
                            thisimg->depth,
                            CV_LOAD_IMAGE_GRAYSCALE);

    ptemp   =(unsigned char*) temp->imageData;
/*
    cout << "chan" << thisimg->nChannels << endl;
    cout << "h" << thisimg->height << endl;
    cout << "w" << thisimg->width << endl;
    cout << "step" << thisimg->widthStep << endl;
    cout << "chan" << temp->nChannels << endl;
    cout << "h" << temp->height << endl;
    cout << "w" << temp->width << endl;
    cout << "step" << temp->widthStep << endl;
*/
    for(k=0;k<thisimg->height;k++){
        l=0;
        //cout << "test1" << endl;
        for(j=0;j<thisimg->width*thisimg->nChannels;j+=thisimg->nChannels){
            ptemp[l]    =ptr[j+(mode-2)];
            l++;
        }
        //cout << "l" << l << endl;
        ptr+=   thisimg->widthStep;
        ptemp+= temp->widthStep;
    }
    cvSaveImage("temp.png",temp);
    cvReleaseImage(&thisimg);
    cvReleaseImage(&temp);
    thisimg     =cvLoadImage("temp.png", CV_LOAD_IMAGE_GRAYSCALE );
}


